Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Scala 3 extension methods (not yet compiling) #11

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mpilquist
Copy link
Member

@mpilquist mpilquist commented Oct 28, 2023

Starting point for #10. The simplified extension methods here don't work for all hierarchy cases:

[error] -- [E007] Type Mismatch Error: /Users/mpilquist/Development/oss/twiddles/core/shared/src/test/scala/examples/Hierarchy.scala:62:33
[error] 62 |  def c: Decoder[Foo] = (int *: (string: Decoder[String]) *: bool).to[Foo]
[error]    |                                 ^^^^^^^^^^^^^^^^^^^^^^^
[error]    |                         Found:    examples.Hierarchy.Decoder[String]
[error]    |                         Required: examples.Hierarchy.Codec[A]
[error]    |
[error]    |                         where:    A is a type variable with constraint
[error]    |
[error]    | longer explanation available when compiling with `-explain`
[error] -- [E007] Type Mismatch Error: /Users/mpilquist/Development/oss/twiddles/core/shared/src/test/scala/examples/Hierarchy.scala:63:26
[error] 63 |  def d: Decoder[Foo] = ((int: Decoder[Int]) *: string *: bool).to[Foo]
[error]    |                          ^^^^^^^^^^^^^^^^^
[error]    |                         Found:    examples.Hierarchy.Decoder[Int]
[error]    |                         Required: examples.Hierarchy.Codec[A]
[error]    |
[error]    |                         where:    A is a type variable with constraint
[error]    |
[error]    | longer explanation available when compiling with `-explain`
[error] -- [E007] Type Mismatch Error: /Users/mpilquist/Development/oss/twiddles/core/shared/src/test/scala/examples/Hierarchy.scala:65:33
[error] 65 |  def f: Encoder[Foo] = (int *: (string: Encoder[String]) *: bool).to[Foo]
[error]    |                                 ^^^^^^^^^^^^^^^^^^^^^^^
[error]    |                         Found:    examples.Hierarchy.Encoder[String]
[error]    |                         Required: examples.Hierarchy.Codec[A]
[error]    |
[error]    |                         where:    A is a type variable with constraint
[error]    |
[error]    | longer explanation available when compiling with `-explain`
[error] -- [E007] Type Mismatch Error: /Users/mpilquist/Development/oss/twiddles/core/shared/src/test/scala/examples/Hierarchy.scala:66:26
[error] 66 |  def g: Encoder[Foo] = ((int: Encoder[Int]) *: string *: bool).to[Foo]
[error]    |                          ^^^^^^^^^^^^^^^^^
[error]    |                         Found:    examples.Hierarchy.Encoder[Int]
[error]    |                         Required: examples.Hierarchy.Codec[A]
[error]    |
[error]    |                         where:    A is a type variable with constraint
[error]    |
[error]    | longer explanation available when compiling with `-explain`
[error] four errors found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant